package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsSpikeNotification;
import com.mall.mapper.SmsSpikeNotificationMapper;
import com.mall.service.SmsSpikeNotificationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsSpikeNotificationServiceImpl extends ServiceImpl<SmsSpikeNotificationMapper, SmsSpikeNotification> implements SmsSpikeNotificationService {

    @Resource
    private SmsSpikeNotificationMapper smsSpikeNotificationMapper;

    @Override
    public SmsSpikeNotification getById(Integer id) {
        return smsSpikeNotificationMapper.selectById(id);
    }

    @Override
    public List<SmsSpikeNotification> getAll() {
        return smsSpikeNotificationMapper.selectList(null);
    }

    @Override
    public boolean save(SmsSpikeNotification smsSpikeNotification) {
        if(smsSpikeNotification.getId() == null)
        {
            return smsSpikeNotificationMapper.insert(smsSpikeNotification) > 0;
        }else{
            return  smsSpikeNotificationMapper.updateById(smsSpikeNotification) > 0;
        }
    }


    @Override
    public boolean deleteById(Integer id) {
        return smsSpikeNotificationMapper.deleteById(id) > 0;
    }
}
